home *** CD-ROM | disk | FTP | other *** search
- /*
-
- TecLis Mail System. by TecLis. Started 13 Jun 1995. ®1995 TecLis Productions.
-
-
- Params passed to Main are :
-
- InitialScan : Only parse the mail area ONCE. Save the messages available to
- : to user.
-
- MAILSCAN : Scans selected conferences (default = All) for messages..
- : Should display a list of them (per conf.)
- : Check for :- To User, Users Groups, All
-
- ENTERMESSAGE : Enters - To, Subject (Date/Time Stored), Private (Depends on user)
-
- READMESSAGE :
-
- ENTERCOMMENT L Enter Message to Sysop/CoSysop
-
-
- todo
- ====
-
- allow typing of message number at the mailscan prompt and when reading a message
-
- allow use of message number after the R command (E.G. R 21 to read message 21)
-
- bugs
- ====
-
- if you have a message with blank lines they are stripped when it is displayed..
-
- check for writing to the same person more than once.. (Hydra,Hydra is currently valid..)
-
- typing R in a conference with NO mail brings up the message
- "Sorry <user>, No Messages have been sent to you"
- when it should read:
- "Sorry Hydra, there is no mail in this conference"
-
- leaves LOADS of memory behind! check all Alloc and Free pairs..
-
-
- */
-
- #define MAILSYSMAIN
-
- #include <dos/dos.h>
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <clib/dos_protos.h>
- #include <clib/exec_protos.h>
- #include <clib/alib_protos.h>
-
- #include <stdlib.h>
- #include <string.h>
- #include <stdio.h>
- #include <ctype.h>
- #include <time.h>
-
-
- #ifdef __SASC
- int CXBRK(void) { return(0); }
- int _CXBRK(void) { return(0); }
- void chkabort(void) {}
- #endif
-
- #include <HBBS/ANSI_Codes.h>
- #include <HBBS/Defines.h>
- #include <HBBS/types.h>
- #include <HBBS/structures.h>
- #include <HBBS/hbbscommon_protos.h>
- #include <HBBS/hbbscommon_pragmas.h>
- #include <HBBS/Hbbsnode_protos.h>
- #include <HBBS/Hbbsnode_pragmas.h>
-
- #include "maildoor.h"
- #include "mailscan.h"
- #include "mailread.h"
- #include "mailedit.h"
-
- ULONG __stack = 20000;
-
- struct Library *HBBSCommonBase=NULL;
- struct Library *HBBSNodeBase=NULL;
-
- struct BBSGlobalData *BBSGlobal=NULL;
- struct NodeData *N_ND=NULL;
- int N_NodeNum=-1;
-
- static VOID cleanup(ULONG num)
- {
- if (HBBSNodeBase)
- {
- HBBS_CleanUpDoor();
- CloseLibrary (HBBSNodeBase);
- }
-
- if (HBBSCommonBase)
- {
- HBBS_CleanUpCommon();
- CloseLibrary (HBBSCommonBase);
- }
-
- if (num) printf("Door Error = %d\n",num);
-
- exit(0);
- }
-
- static VOID init(char *name)
- {
- if(!(HBBSCommonBase = OpenLibrary("HBBSCommon.library",0)))
- {
- cleanup(1);
- }
-
- if (!(HBBS_InitCommon()))
- {
- cleanup(2);
- }
-
- if(!(HBBSNodeBase = OpenLibrary("HBBSNode.library",0)))
- {
- cleanup(3);
- }
-
- if (!(HBBS_InitDoor(N_NodeNum,name)))
- {
- cleanup(4);
- }
- SetProgramName(name);
- }
-
- BOOL MYDOOR_SetupGlobals( int argc, char *argv[] )
- {
- int loop, n;
-
- // Setup Paths for Mail System
-
- if( MSys_MainPath = AllocVec( MAX_PATH_LENGTH, MEMF_PUBLIC|MEMF_CLEAR ) )
- {
- loop = strlen( argv[0] )-1;
-
- while( (argv[0][loop] != '/') && (argv[0][loop] != ':' ) ) loop--;
-
- for( n = 0; n <= loop; n++ ) MSys_MainPath[n] = argv[0][n] ;
-
- }
- else
- {
- // Fucked UP!
- return( FALSE );
- }
-
- return( TRUE );
- }
-
- void MYDOOR_ClearGlobals( void )
- {
- if( MSys_MainPath ) FreeVec( MSys_MainPath );
- }
-
- void MYDOOR_DisplayDoorHelp( void )
- {
- DOOR_WriteText( "No operation requested!\r\n" );
- }
-
- void MYDOOR_DisplayTecLisMailHeader( void )
- {
- char outstr[BUFFER_LENGTH];
-
- sprintf( outstr, "%s%sTecLis Mail Reader. ©1995 TecLis Productions. By TecLis/TEP%s%s\r\n\r\n", ANSI_FG_YELLOW, ANSI_BG_BLUE, ANSI_FG_WHITE, ANSI_BG_BLACK );
- DOOR_WriteText( outstr );
- }
-
- int MYDOOR_GetOptionNumber( int argc, char *argv[] )
- {
- int option = MSys_OPT_OPTUNKNOWN;
- BOOL Found = FALSE;
-
- if( N_ND->ActiveDoor->SystemOptions )
- {
- if( iposition( "MAILSCAN", N_ND->ActiveDoor->SystemOptions ) >=0 )
- {
- Found = TRUE;
- option = MSys_OPT_MAILSCAN;
- }
- else
- {
- if( iposition( "READMESSAGES", N_ND->ActiveDoor->SystemOptions ) >=0 )
- {
- Found = TRUE;
- option = MSys_OPT_READMESSAGE;
- }
- else
- {
- if( iposition( "ENTERMESSAGE", N_ND->ActiveDoor->SystemOptions ) >=0 )
- {
- Found = TRUE;
- option = MSys_OPT_ENTERMESSAGE;
- }
- else
- {
- if( iposition( "ENTERCOMMENT", N_ND->ActiveDoor->SystemOptions ) >=0 )
- {
- Found = TRUE;
- option = MSys_OPT_ENTERCOMMENT;
- }
- }
- }
- }
- }
- return( option );
- }
-
- void DoorMain( int argc,char *argv[] )
- {
- char outstr[100];
-
-
- if( MYDOOR_SetupGlobals( argc, argv ) )
- {
- if( argc < 2 )
- MYDOOR_DisplayDoorHelp();
- else
- {
- switch( MYDOOR_GetOptionNumber( argc, argv ) )
- {
- case MSys_OPT_OKAY:
- sprintf( outstr, "No operation requested!\r\n" );
- DOOR_WriteText( outstr );
- break;
- case MSys_OPT_MAILSCAN:
- MYDOOR_DoMailScan( argc, argv );
- break;
- case MSys_OPT_ENTERMESSAGE:
- MYDOOR_DoEnterMessage( NULL );
- break;
- case MSys_OPT_READMESSAGE:
- MYDOOR_DoReadMail( argc, argv );
- break;
- case MSys_OPT_OPTUNKNOWN:
- sprintf( outstr, "Option unknown!\r\n" );
- DOOR_WriteText( outstr );
- break;
- case MSys_OPT_ENTERCOMMENT:
- MYDOOR_DoEnterMessage( "SYSOP" );
- break;
- }
- }
- }
- else
- {
- DOOR_WriteText( "There were problems\r\n" );
- }
- MYDOOR_ClearGlobals();
-
- }
-
- int main(int argc,char *argv[])
- {
- if (sscanf(argv[1],"%d",&N_NodeNum)==0)
- {
- printf("Invalid/No Paramaters for door!\n");
- exit (20);
- }
- init("TecLis Mail System");
-
- if (BBSGlobal=HBBS_GimmeBBS())
- {
- if (N_ND=HBBS_NodeDataPtr(N_NodeNum)) // this should not fail in normal circumstances..
- {
- DoorMain(argc,argv);
- }
- }
- cleanup(0);
- }
-